﻿using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using DXApplicationTangche.report;
using DXApplicationTangche.UC.项目成果管理.service;
using DXApplicationTangche.UC.项目流程.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.项目流程
{
    public partial class Form任务完成扫员工 : Form
    {
        private String reportPath;
        private OrderTaskDTO orderTaskDTO;
        public Form任务完成扫员工(OrderTaskDTO orderTaskDTO)
        {
            InitializeComponent();
            this.orderTaskDTO = orderTaskDTO;
        }
        public Form任务完成扫员工(OrderTaskDTO orderTaskDTO, String reportPath)
        {
            InitializeComponent();
            this.orderTaskDTO = orderTaskDTO;
            this.reportPath = reportPath;
        }
        
        private void textBox扫描_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                try
                {
                    if (String.IsNullOrEmpty(this.textBox扫描.Text))
                    {
                        MessageBox.Show("无扫描信息");
                        return;
                    }
                    //判断扫描的工牌是否正确
                    String mnemonic = 项目成果Service.get判断扫描员工码是否正确(this.textBox扫描.Text.Trim());
                    if (String.IsNullOrWhiteSpace(mnemonic))
                    {
                        this.textBox扫描.Clear();
                        MessageBox.Show("扫描员工码错误，请重新扫描");
                        return;
                    }
                    if ("SAMPLEPREPARATION_001".Equals(this.orderTaskDTO.code))
                    {
                        String re = 
                            流程Service.taskDoneWithAchievem(this.orderTaskDTO.id, "liyan01", "有成果物提交", reportPath);
                    }
                    else
                    {
                        流程Service.taskDone(this.orderTaskDTO.id, "liyan01", "无成果物提交");
                    }
                    MessageBox.Show("操作完成");
                    this.Close();
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }

            }
        }
    }
}
